using System;
using System.Configuration;

namespace NWrapper.Config
{
	/// <summary>
	/// The NWrapper configuration section.
	/// </summary>
	public class NWrapperSection : ConfigurationSection
	{
		/// <summary>
		/// Default constructor.
		/// </summary>
		public NWrapperSection()
			: base()
		{
		}

		/// <summary>
		/// Gets or sets the logging type to be used.
		/// </summary>
		[ConfigurationProperty("logger", DefaultValue = LoggerType.None, IsRequired = false)]
		public LoggerType Logger
		{
			get { return (LoggerType)this["logger"]; }
			set { this["logger"] = value; }
		}

		/// <summary>
		/// Gets or sets the cache type to be used.
		/// </summary>
		[ConfigurationProperty("cache", IsRequired = false)]
		public CacheSettings Cache
		{
			get
			{
				if (this["cache"] == null)
					return CacheSettings.Default;
				else
					return (CacheSettings)this["cache"];
			}
			set { this["cache"] = value; }
		}

		/// <summary>
		/// Gets or sets the repositories (data mappers) to be used.
		/// </summary>
		[ConfigurationProperty("repositories")]
		public ConfigurationElementCollection<RepositorySettings> Repositories
		{
			get { return (ConfigurationElementCollection<RepositorySettings>)base["repositories"]; }
			set { base["repositories"] = value; }
		}
	}
}
